<template>
  <div>
    <el-table ref="hcTable" :data="tableData" :border="viewConfig.bordered" :header-cell-style="{ background: viewConfig.theadColor }" style="width: 100%" :row-key="(row) => row.unid || 0 + '_' + row.xh" stripe @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="45" :reserve-selection="true">
      </el-table-column>
      <el-table-column :label="columnsItem.title" :width="columnsItem.width" v-for="(columnsItem, index) in columns" :key="index" :align="columnsItem.align" :fixed="columnsItem.key == 'action' ? 'right' : false">
        <template slot="header" slot-scope="scope">
          <span v-html="scope.column.label"></span>
        </template>
        <template slot-scope="scope">
          <HCViewItem :text="scope.row[columnsItem.key]" :record="scope.row" :otherObj="{}" :columnsItem="columnsItem" :buttonsList="[]"></HCViewItem>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { getList } from "../../api/common/bwgzApi";
import { mapState, mapGetters } from "vuex";
import { viewConfig } from "@/utils/coreConfig";
// 分页组件
import Pagination from "@/components/Pagination";
export default {
  name: "FollowOffice",
  components: {
    //解决嵌套引入的问题
    HCViewItem: () => import("../../HCView/components/HCViewItem.vue"),
    Pagination,
  },
  props: ["unid", "modulename"],
  computed: {
    ...mapGetters(["userInfo"]),
    ...mapState("dict", ["DICT_bw_state"])
  },
  data()
  {
    return {
      viewConfig,
      columns: [{
        title: "状态",
        dataIndex: "state",
        key: "state",
        type: "KVLIST",
        width: 50,
        viewProp: {
          defaultValue: ""
        },
        isSort: false
      },
      {
        title: "办理人",
        dataIndex: "ownerFullname",
        key: "ownerFullname",
        type: "TEXT",
      },
      {
        title: "所在部门",
        dataIndex: "ownerOrgFullname",
        key: "ownerOrgFullname",
        type: "TEXT"
      },
      {
        title: "操作",
        dataIndex: "flowStructureNodeIdent",
        key: "flowStructureNodeIdent",
        type: "TEXT",
        width: 100
      },
      {
        title: "送文时间",
        dataIndex: "receiveTime",
        key: "receiveTime",
        type: "TEXT",
        width: 150
      }
      ],
      tableData: [],
      records: [], //勾选项
      unid: 0,
      //总数
      totalCount: 0,
      //当前页码
      currentpage: 1,
      //每页数量
      pageSize: 1000,
      //查询参数
      queryParam: {
      }
    };
  },
  methods: {
    //监听列表勾选
    handleSelectionChange(selection)
    {
      this.records = selection;
    },
    //获取办文数据
    getTableData(unid)
    {
      this.unid = unid;
      this.queryParam.pageSize = this.pageSize;
      this.queryParam.pageNo = this.currentpage;
      this.queryParam.wjId = unid;
      this.queryParam.modulename = this.modulename;
      console.log("请求参数", this.queryParam);
      getList(this.queryParam).then(res =>
      {
        this.columns[0].viewProp.defaultValue = JSON.stringify(this.DICT_bw_state)
        let lcgzList = res.result.data || [];
        this.tableData = [];
        lcgzList.forEach(pre_lcgz =>
        {
          if (pre_lcgz.state == 8 && pre_lcgz.ownerIdent != this.userInfo.unid && pre_lcgz.bwtr_ident != this.userInfo.unid)
          {
            this.tableData.push(pre_lcgz);
          }
        });

        this.totalCount = res.result.totalCount || 0;
      })
    }
  },

};
</script>
